<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>hello</title>
    <link href="/static/js/select2/select2.css" rel="stylesheet">
    <script src="/static/js/jquery/jquery-2.1.0.min.js"></script>
    <script src="/static/js/select2/select2.min.js"></script>
</head>
<body>
<select id="select1" readonly="true">
    <option value="-1">请选择</option>
</select>
<script type="application/javascript">
    function aaa() {
        var html = '<option selected="selected" value="11111">中国农业银行</option>';
        $("#select1").empty().append(html);
    }
</script>


<br>
<input type="button" value="111" onclick="aaa()">

<!--#{name}-->
<div style="align-content: center">
    <input id="select2" type="text">
    <!--<select id="select2">-->
        <!--<option>&#45;&#45; 请选择 &#45;&#45;</option>-->
    <!--</select>-->
</div>
</body>
<script type="application/javascript">
    function aaa() {
        var html = '<option selected="selected" value="11111">中国农业银行</option>';
        $("#select1").empty().append(html);
    }
    $(document).ready(function () {
        $("#select2").select2({
            placeholder: "Select report type", //提示语
            allowClear: true, //允许清空
            minimumInputLength: 2,　　//{# 最小查询参数    #}
            selectOnClose: true, // 结果显示高亮
            ajax: {
                url: '/data',
                dataType: "json",
                type: "POST",
                quietMillis: 1000,
                data: function (term, page) {
                    console.log(term);
                    console.log(page);
                    return {
                        sSearch: term, //{# term为前台输入的查询关键字，保存到sSearch对象，即后台保存关键字的对象 #}
                        page: 10   //{# 每次查询的结果数 #}
                    };
                },
                results: function (data, page) {
                    var dataObj =eval(data);
                    console.log(dataObj);
                    console.log(page);
                    return {
                        results: dataObj  //{# results结果集，data为后台返回的查询结果 #}
                    };
                },
                formatResult: function (data, params) {
                    console.log(data);
                    console.log(params);
                    return data.name;
                }
            }
        });
    });
</script>
</html>